import variables from '@/assets/styles/element-variables.scss'
import variablesMenu from '@/assets/styles/variables.scss'
import defaultSettings from '@/settings'
import Cookies from 'js-cookie'
const { tagsView, fixedHeader, sidebarLogo, showFooter, footerTxt, caseNumber } = defaultSettings
const state = {
  theme: variables.theme,
  showSettings: false,
  tagsView: tagsView,
  fixedHeader: fixedHeader,
  sidebarLogo: sidebarLogo,
  showFooter: showFooter,
  footerTxt: footerTxt,
  caseNumber: caseNumber,
  layout: 'vertical',
  menuText: Cookies.get('menuText') ? Cookies.get('menuText') : variablesMenu.menuText,
  menuActiveText: Cookies.get('menuActiveText') ? Cookies.get('menuActiveText') : variablesMenu.menuActiveText,
  menuBg: Cookies.get('menuBg') ? Cookies.get('menuBg') : variablesMenu.menuBg,
  subMenuActiveText: Cookies.get('subMenuActiveText') ? Cookies.get('subMenuActiveText') : variablesMenu.subMenuActiveText,
  menuHover: Cookies.get('menuHover') ? Cookies.get('menuHover') : variablesMenu.menuHover,
  subMenuBg: Cookies.get('subMenuBg') ? Cookies.get('subMenuBg') : variablesMenu.subMenuBg,
  subMenuHover: Cookies.get('subMenuHover') ? Cookies.get('subMenuHover') : variablesMenu.subMenuHover
}

const mutations = {
  CHANGE_SETTING: (state, { key, value }) => {
    if (state.hasOwnProperty(key)) {
      state[key] = value
    }
  }
}

const actions = {
  changeSetting({ commit }, data) {
    commit('CHANGE_SETTING', data)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}

